/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 投票活动数据
	/// module : structs
	/// </summary>
	public class VoteDataPOD : IPOD 
    {
        public readonly static Func<VoteDataPOD> FACTORY = () => new VoteDataPOD();
		public static Func<VoteDataPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 我的投票记录
        /// </summary>
        private Dictionary<int, int> m_myVotes;
		
		
        public Dictionary<int, int> myVotes
        {
            get
            {
                if(m_myVotes == null)
                {
                    m_myVotes = new();
                }
                return m_myVotes;
            }
            private set => m_myVotes = value;
        }
        public Dictionary<int, int> unsafe_myVotes
        {
        	get => m_myVotes;
        	set => m_myVotes = value;
        }
		
		/*-- constructors --*/
		public VoteDataPOD() {}
		public VoteDataPOD(Dictionary<int, int> myVotes) {
			this.m_myVotes = myVotes;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_map_int_int(m_myVotes);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            m_myVotes = _in.Read_map_int_int();
        }
		
		public VoteDataPOD Clone() {
            VoteDataPOD o = DynamicFactory();
            if (m_myVotes != null) {
                o.m_myVotes = new (m_myVotes);
            }
            return o;
        }
        
        public void Clear() {
            m_myVotes = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "VoteDataPOD [";
			str += "myVotes=";
			str += m_myVotes.ToString<int, int>();
			str += "]";
			return str;
		}
		
	}
}